from itsdangerous import TimedJSONWebSignatureSerializer
from meiduo import settings

#TimedJSONWebSignatureSerializer(secret_key=密钥,expires_in=加密后有效期（秒）)
miyao=TimedJSONWebSignatureSerializer(secret_key=settings.SECRET_KEY,expires_in=60*30)
def encryption(data):
    """加密"""
    return miyao.dumps(data).decode()


def decrypt(data):
    """解密"""
    return miyao.loads(data)

class jiami:
    def __init__(self,secret_key=settings.SECRET_KEY, expires_in=60 * 30):
        self.miyao = TimedJSONWebSignatureSerializer(secret_key,expires_in)

    def encryption(self,data):
        """加密"""
        return self.miyao.dumps(data).decode()

    def decrypt(self,data):
        """解密"""
        return self.miyao.loads(data)








